.class Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;
.super Landroid/os/AsyncTask;
.source "RemoteImageView.java"


# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/bitauto/autoeasy/widget/RemoteImageView;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x0
    name = "DownloadTask"
.end annotation

.annotation system Ldalvik/annotation/Signature;
    value = {
        "Landroid/os/AsyncTask",
        "<",
        "Ljava/lang/String;",
        "Ljava/lang/Void;",
        "Ljava/lang/String;",
        ">;"
    }
.end annotation


# instance fields
.field private mTaskUrl:Ljava/lang/String;

.field final synthetic this$0:Lcom/bitauto/autoeasy/widget/RemoteImageView;


# direct methods
.method constructor <init>(Lcom/bitauto/autoeasy/widget/RemoteImageView;)V
    .locals 0
    .parameter

    .prologue
    .line 246
    iput-object p1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;->this$0:Lcom/bitauto/autoeasy/widget/RemoteImageView;

    invoke-direct {p0}, Landroid/os/AsyncTask;-><init>()V

    return-void
.end method


# virtual methods
.method public bridge varargs synthetic doInBackground([Ljava/lang/Object;)Ljava/lang/Object;
    .locals 1
    .parameter

    .prologue
    .line 1
    check-cast p1, [Ljava/lang/String;

    invoke-virtual {p0, p1}, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;->doInBackground([Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method public varargs doInBackground([Ljava/lang/String;)Ljava/lang/String;
    .locals 7
    .parameter "params"

    .prologue
    const-string v4, "Failed to cache "

    .line 259
    const/4 v4, 0x0

    aget-object v4, p1, v4

    iput-object v4, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;->mTaskUrl:Ljava/lang/String;

    .line 260
    const/4 v3, 0x0

    .line 262
    .local v3, stream:Ljava/io/InputStream;
    const/4 v0, 0x0

    .line 265
    .local v0, bmp:Landroid/graphics/Bitmap;
    :try_start_0
    new-instance v2, Ljava/net/URL;

    iget-object v4, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;->mTaskUrl:Ljava/lang/String;

    invoke-direct {v2, v4}, Ljava/net/URL;-><init>(Ljava/lang/String;)V
    :try_end_0
    .catch Ljava/net/MalformedURLException; {:try_start_0 .. :try_end_0} :catch_3

    .line 267
    .local v2, imageUrl:Ljava/net/URL;
    :try_start_1
    invoke-virtual {v2}, Ljava/net/URL;->openStream()Ljava/io/InputStream;

    move-result-object v3

    .line 268
    invoke-static {v3}, Landroid/graphics/BitmapFactory;->decodeStream(Ljava/io/InputStream;)Landroid/graphics/Bitmap;
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0
    .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_1

    move-result-object v0

    .line 270
    if-eqz v0, :cond_1

    .line 271
    :try_start_2
    invoke-static {}, Lcom/bitauto/autoeasy/autoEasyApplication;->getInstance()Lcom/bitauto/autoeasy/autoEasyApplication;

    move-result-object v4

    invoke-virtual {v4}, Lcom/bitauto/autoeasy/autoEasyApplication;->getImageCache()Lcom/bitauto/autoeasy/tool/ImageCache;

    move-result-object v4

    iget-object v5, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;->mTaskUrl:Ljava/lang/String;

    invoke-virtual {v4, v5, v0}, Lcom/bitauto/autoeasy/tool/ImageCache;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 272
    invoke-static {}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->access$1()Ljava/lang/String;

    move-result-object v4

    new-instance v5, Ljava/lang/StringBuilder;

    const-string v6, "Image cached "

    invoke-direct {v5, v6}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    iget-object v6, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;->mTaskUrl:Ljava/lang/String;

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    invoke-static {v4, v5}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0
    .catch Ljava/lang/NullPointerException; {:try_start_2 .. :try_end_2} :catch_0
    .catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_1

    .line 283
    :goto_0
    if-eqz v3, :cond_0

    .line 284
    :try_start_3
    invoke-virtual {v3}, Ljava/io/InputStream;->close()V
    :try_end_3
    .catch Ljava/io/IOException; {:try_start_3 .. :try_end_3} :catch_5
    .catch Ljava/net/MalformedURLException; {:try_start_3 .. :try_end_3} :catch_3

    .line 292
    .end local v2           #imageUrl:Ljava/net/URL;
    :cond_0
    :goto_1
    iget-object v4, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;->mTaskUrl:Ljava/lang/String;

    return-object v4

    .line 274
    .restart local v2       #imageUrl:Ljava/net/URL;
    :cond_1
    :try_start_4
    invoke-static {}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->access$1()Ljava/lang/String;

    move-result-object v4

    new-instance v5, Ljava/lang/StringBuilder;

    const-string v6, "Failed to cache "

    invoke-direct {v5, v6}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    iget-object v6, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;->mTaskUrl:Ljava/lang/String;

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    invoke-static {v4, v5}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_0
    .catch Ljava/lang/NullPointerException; {:try_start_4 .. :try_end_4} :catch_0
    .catch Ljava/io/IOException; {:try_start_4 .. :try_end_4} :catch_1

    goto :goto_0

    .line 276
    :catch_0
    move-exception v4

    move-object v1, v4

    .line 277
    .local v1, e:Ljava/lang/NullPointerException;
    :try_start_5
    invoke-static {}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->access$1()Ljava/lang/String;

    move-result-object v4

    new-instance v5, Ljava/lang/StringBuilder;

    const-string v6, "Failed to cache "

    invoke-direct {v5, v6}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    iget-object v6, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;->mTaskUrl:Ljava/lang/String;

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    invoke-static {v4, v5}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I
    :try_end_5
    .catchall {:try_start_5 .. :try_end_5} :catchall_0
    .catch Ljava/io/IOException; {:try_start_5 .. :try_end_5} :catch_1

    goto :goto_0

    .line 279
    .end local v1           #e:Ljava/lang/NullPointerException;
    :catch_1
    move-exception v4

    move-object v1, v4

    .line 280
    .local v1, e:Ljava/io/IOException;
    :try_start_6
    invoke-static {}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->access$1()Ljava/lang/String;

    move-result-object v4

    new-instance v5, Ljava/lang/StringBuilder;

    const-string v6, "Couldn\'t load bitmap from url: "

    invoke-direct {v5, v6}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    iget-object v6, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;->mTaskUrl:Ljava/lang/String;

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    invoke-static {v4, v5}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I
    :try_end_6
    .catchall {:try_start_6 .. :try_end_6} :catchall_0

    .line 283
    if-eqz v3, :cond_0

    .line 284
    :try_start_7
    invoke-virtual {v3}, Ljava/io/InputStream;->close()V
    :try_end_7
    .catch Ljava/io/IOException; {:try_start_7 .. :try_end_7} :catch_2
    .catch Ljava/net/MalformedURLException; {:try_start_7 .. :try_end_7} :catch_3

    goto :goto_1

    .line 286
    :catch_2
    move-exception v4

    goto :goto_1

    .line 281
    .end local v1           #e:Ljava/io/IOException;
    :catchall_0
    move-exception v4

    .line 283
    if-eqz v3, :cond_2

    .line 284
    :try_start_8
    invoke-virtual {v3}, Ljava/io/InputStream;->close()V
    :try_end_8
    .catch Ljava/io/IOException; {:try_start_8 .. :try_end_8} :catch_4
    .catch Ljava/net/MalformedURLException; {:try_start_8 .. :try_end_8} :catch_3

    .line 287
    :cond_2
    :goto_2
    :try_start_9
    throw v4
    :try_end_9
    .catch Ljava/net/MalformedURLException; {:try_start_9 .. :try_end_9} :catch_3

    .line 289
    .end local v2           #imageUrl:Ljava/net/URL;
    :catch_3
    move-exception v4

    move-object v1, v4

    .line 290
    .local v1, e:Ljava/net/MalformedURLException;
    invoke-virtual {v1}, Ljava/net/MalformedURLException;->printStackTrace()V

    goto :goto_1

    .line 286
    .end local v1           #e:Ljava/net/MalformedURLException;
    .restart local v2       #imageUrl:Ljava/net/URL;
    :catch_4
    move-exception v5

    goto :goto_2

    :catch_5
    move-exception v4

    goto :goto_1
.end method

.method public bridge synthetic onPostExecute(Ljava/lang/Object;)V
    .locals 0
    .parameter

    .prologue
    .line 1
    check-cast p1, Ljava/lang/String;

    invoke-virtual {p0, p1}, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;->onPostExecute(Ljava/lang/String;)V

    return-void
.end method

.method public onPostExecute(Ljava/lang/String;)V
    .locals 4
    .parameter "url"

    .prologue
    .line 297
    invoke-super {p0, p1}, Landroid/os/AsyncTask;->onPostExecute(Ljava/lang/Object;)V

    .line 300
    iget-object v1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;->mTaskUrl:Ljava/lang/String;

    iget-object v2, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;->this$0:Lcom/bitauto/autoeasy/widget/RemoteImageView;

    invoke-static {v2}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->access$2(Lcom/bitauto/autoeasy/widget/RemoteImageView;)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v1

    if-nez v1, :cond_1

    .line 317
    :cond_0
    :goto_0
    return-void

    .line 303
    :cond_1
    invoke-static {}, Lcom/bitauto/autoeasy/autoEasyApplication;->getInstance()Lcom/bitauto/autoeasy/autoEasyApplication;

    move-result-object v1

    invoke-virtual {v1}, Lcom/bitauto/autoeasy/autoEasyApplication;->getImageCache()Lcom/bitauto/autoeasy/tool/ImageCache;

    move-result-object v1

    invoke-virtual {v1, p1}, Lcom/bitauto/autoeasy/tool/ImageCache;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/graphics/Bitmap;

    .line 304
    .local v0, bmp:Landroid/graphics/Bitmap;
    if-nez v0, :cond_2

    .line 305
    invoke-static {}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->access$1()Ljava/lang/String;

    move-result-object v1

    new-instance v2, Ljava/lang/StringBuilder;

    const-string v3, "Trying again to download "

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v2, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-static {v1, v2}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I

    .line 306
    iget-object v1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;->this$0:Lcom/bitauto/autoeasy/widget/RemoteImageView;

    invoke-virtual {v1, p1}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->setImageUrl(Ljava/lang/String;)V

    goto :goto_0

    .line 310
    :cond_2
    iget-object v1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;->this$0:Lcom/bitauto/autoeasy/widget/RemoteImageView;

    invoke-static {v1}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->access$3(Lcom/bitauto/autoeasy/widget/RemoteImageView;)Landroid/widget/ListView;

    move-result-object v1

    if-eqz v1, :cond_3

    .line 311
    iget-object v1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;->this$0:Lcom/bitauto/autoeasy/widget/RemoteImageView;

    invoke-static {v1}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->access$4(Lcom/bitauto/autoeasy/widget/RemoteImageView;)I

    move-result v1

    iget-object v2, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;->this$0:Lcom/bitauto/autoeasy/widget/RemoteImageView;

    invoke-static {v2}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->access$3(Lcom/bitauto/autoeasy/widget/RemoteImageView;)Landroid/widget/ListView;

    move-result-object v2

    invoke-virtual {v2}, Landroid/widget/ListView;->getFirstVisiblePosition()I

    move-result v2

    if-lt v1, v2, :cond_0

    iget-object v1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;->this$0:Lcom/bitauto/autoeasy/widget/RemoteImageView;

    invoke-static {v1}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->access$4(Lcom/bitauto/autoeasy/widget/RemoteImageView;)I

    move-result v1

    iget-object v2, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;->this$0:Lcom/bitauto/autoeasy/widget/RemoteImageView;

    invoke-static {v2}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->access$3(Lcom/bitauto/autoeasy/widget/RemoteImageView;)Landroid/widget/ListView;

    move-result-object v2

    invoke-virtual {v2}, Landroid/widget/ListView;->getLastVisiblePosition()I

    move-result v2

    if-gt v1, v2, :cond_0

    .line 314
    :cond_3
    iget-object v1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;->this$0:Lcom/bitauto/autoeasy/widget/RemoteImageView;

    invoke-virtual {v1, v0}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->setImageBitmap(Landroid/graphics/Bitmap;)V

    .line 315
    iget-object v1, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;->this$0:Lcom/bitauto/autoeasy/widget/RemoteImageView;

    invoke-static {v1, p1}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->access$5(Lcom/bitauto/autoeasy/widget/RemoteImageView;Ljava/lang/String;)V

    goto :goto_0
.end method

.method public onPreExecute()V
    .locals 1

    .prologue
    .line 252
    iget-object v0, p0, Lcom/bitauto/autoeasy/widget/RemoteImageView$DownloadTask;->this$0:Lcom/bitauto/autoeasy/widget/RemoteImageView;

    invoke-static {v0}, Lcom/bitauto/autoeasy/widget/RemoteImageView;->access$0(Lcom/bitauto/autoeasy/widget/RemoteImageView;)V

    .line 253
    invoke-super {p0}, Landroid/os/AsyncTask;->onPreExecute()V

    .line 254
    return-void
.end method
